package com.example.zlx.service.impl;

import com.example.zlx.entity.Surrou;
import com.example.zlx.repository.SurrouRepository;

import com.example.zlx.service.SurrouService;
import com.example.zlx.util.ServerResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SurrouServiceImpl  implements SurrouService {
    @Autowired
    private SurrouRepository surrouRepository;
    @Override
    public ServerResponse<Surrou> getPlumberById(Integer id) {
        Surrou  surrouInfo=surrouRepository.findOne(id);
        if( surrouInfo==null){
            return ServerResponse.createByErrorMessage("没有相应的id");
        }
        return ServerResponse.createBySuccess("查找成功", surrouInfo);
    }

    @Override
    public ServerResponse list() {
        List<Surrou> list= surrouRepository.findAll();
        return ServerResponse.createBySuccess(list);
    }
}
